package com.supermap.application.service;

import com.supermap.application.dao.IndustryDao;
import com.supermap.application.entity.TIndustry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IndustryService {

    @Autowired
    IndustryDao industryDao;

    /**
     * 根据行业代码获取行业对象
     * @param A00011
     * @return
     */
    public TIndustry getIndustryByCode(String A00011){
        return industryDao.findOneByA00011(A00011);
    }

    /**
     * 根据行业代码获取行业名称
     * @param code
     * @return
     */
    public String getIndustryNameByCode(String code){
        //针对部分行业代码查询不到问题, 取两位行业代码
        if (code.length() > 2){
            code = code.substring(0,2);
        }
        TIndustry industry = getIndustryByCode(code);
        if (industry != null) {
            return industry.getIndustryName();
        }else {
            return "";
        }
    }
}
